package com.learn.thread.demo03;

/**
 * 线程中断
 * @author Java丶小明
 * @date 2021/6/25 16:32
 */
public class ThreadDemo {
    public static void main(String[] args) {
//        testThread();
        testRunnable();
    }

    private static void testThread(){
        Thread task = new PrimeGenerator01();
        task.start();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //中断线程
        task.interrupt();
    }

    private static void testRunnable(){
        Thread task = new Thread(new PrimeGenerator02());
        task.start();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //中断线程
        task.interrupt();
    }
}
